u"""
OverFish CMS

Created on: Jul 10, 2011 2:26:06 PM

@author: Tomas Holub (tomas.holub@olc.cz)
@package: modDefault

Views for modDefault module
u"""
import overfish

from django.shortcuts import render_to_response
from django.conf import settings
from django.template.context import RequestContext

def dashboard(request):
    u"""
        View renders dashboard items from installed modules 
        and shows them on the dashboard page
    """
    c = {}
    c[u"modules"] = []
    for identifier, title in settings.OVERFISH_INSTALLED_MODULES.iteritems():
        content = u""
        mod = "overfish." + identifier + ".views.backend"
        __import__(mod, globals(), locals(), [], -1)
        content = eval(mod + u".dashboard(request)")
        c[u"modules"].append({
                                u"title": title,
                                u"content": content
                                })
    return render_to_response(u"modDefault/dashboard.html", c,
                              context_instance=RequestContext(request))